﻿using NUnit.Framework;
using WeBlog.ActionResults;
using WeBlog.Controllers;
using WeBlog.DataContext;
using WeBlog.Interfaces;
using WeBlog.Repositories;
using WeBlog.Services;

namespace WeBlog.Tests.Controllers {
	[TestFixture]
	public class ServiceControllerTests {
		
		private IUnitOfWork _unitOfWork;

		[SetUp]
		public void Setup()
		{
			_unitOfWork = new InMemoryUnitOfWork();            
		}

		[Test]
		public void When_RSS_Format_Selected_Feed_Should_Return_RSSActionResult()
		{
			//Arrange            
			var controller = new ServicesController(_unitOfWork);
			SiteManager.CurrentConfiguration.FeedFormat = "Rss";

			//Act
			var rss = controller.Feed();            

			//Assert
			Assert.IsInstanceOf(typeof(RssActionResult),rss);            
		}

		[Test]
		public void When_Atom_Format_Selected_Feed_Should_Return_AtomActionResult()
		{
			//Arrange            
			var controller = new ServicesController(_unitOfWork);
			SiteManager.CurrentConfiguration.FeedFormat = "Atom";

			//Act
			var atom = controller.Feed();

			//Assert
			Assert.IsInstanceOf(typeof(AtomActionResult), atom);
		}

		[Test]
		public void Sitemap_Action_Should_Return_Sitemap_ActionResult()
		{
			//Arrange
			var controller = new ServicesController(_unitOfWork);

			//Act
			var result = controller.Sitemap();

			//Assert
			Assert.IsInstanceOf(typeof(SitemapActionResult),result);
		}
	}
}
